package com.homwee.factory;

import java.util.ArrayList;
import java.util.List;

//zcj 2018-10-31 import com.changhong.inface.net.NetworkSettingUtils;
//zcj 2018-10-31 import com.changhong.inface.net.wifi.WifiAccessPoint;

import com.homwee.tvap.common.ap.ComSettingManager;
import com.homwee.tvap.common.srvfunc.FactorySetting;
import com.mediatek.twoworlds.factory.MtkTvFApiInformation;
import android.app.Activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
//zcj 2018-10-31 import android.os.storage.StorageVolume;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import com.homwee.factory.R;

public class CHFactoryCheckActivity extends Activity {
	public static Context mContext;
	private ListView mListView;
	private List<String> mDatas = new ArrayList<String>();
	public final String TAG = "zcj";

	ArrayAdapter<String> adapter;
	public int bt_count = 0;

	public ComSettingManager mcomSettingManager;
	public FactorySetting factorySetting;

	private static String[] TestRet = { "PANEL:", "PQ:", "AQ:"};
	private String retFilePath = "/vendor/tvcertificate/TestResult.ini";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mContext = this;
		mcomSettingManager = ComSettingManager.getInstance(this);
		factorySetting = mcomSettingManager.getFactory();
		setContentView(R.layout.menu_information_list);
		initData();
		mListView = (ListView) findViewById(R.id.listInfoView);
		adapter = new ArrayAdapter<String>(mContext,
				R.layout.simple_list_item_2, mDatas);
		mListView.setAdapter(adapter);

		mListView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				/*
				// TODO Auto-generated method stub
				String mSelName = ((TextView) arg1).getText().toString();
				factorySetting.setPanelName(mSelName);
				Intent intent = new Intent();
				intent.putExtra("PANEL_NAME", mSelName); 
				setResult(100, intent);
				
				finish();
				*/
			}
		});

		mListView.setSelector(R.drawable.settings_item_selector);
	}

	private void initData() {
		mDatas.clear();
		for (int i = 0; i < TestRet.length; i++) {
			String name = TestRet[i];
			String createret = MtkTvFApiInformation.getInstance().getIniParameter(retFilePath,TestRet[i]+"CreateIni");
			String setret = MtkTvFApiInformation.getInstance().getIniParameter(retFilePath,TestRet[i]+"SetIni");
			String copyret = MtkTvFApiInformation.getInstance().getIniParameter(retFilePath,TestRet[i]+"CopyIni");

			Log.v("zcj", "add name =" + name);
			mDatas.add(TestRet[i]+"create "+createret);
			mDatas.add(TestRet[i]+"set "+setret);
			mDatas.add(TestRet[i]+"copy "+copyret);
		}

	}

	public boolean onKeyDown(int keyCode, KeyEvent event) {

		switch (keyCode) {
		case KeyEvent.KEYCODE_3D_MODE:
		case KeyEvent.KEYCODE_SETTINGS:
		case KeyEvent.KEYCODE_MENU:
		case KeyEvent.KEYCODE_BACK: 
			this.finish();
			Log.v("KEYCODE_MENU", "KEYCODE_MENU=" + KeyEvent.KEYCODE_MENU);
			return true;
		default:

			break;
		}
		return super.onKeyDown(keyCode, event);

	}

}
